<?php
//------------------------------------------------------------------------------
// Class              : Ctl_Huongdan
// Modification       :
//------------------------------------------------------------------------------
// Date(yyyy.mm.dd)   Developer                       Action
//------------------------------------------------------------------------------
// 2007.03.15         Oanhhtk                         Created
//------------------------------------------------------------------------------

class Ctl_Huongdan extends ControlBase{
    var $modul="chinhsach";
    //==========================================================================
    // Function    : Ctl_Huongdan
    // Creator     : Oanhhtk 2007.03.15
    // Details     : Call the constructor of father class to initial variable
    //==========================================================================
    function Ctl_Huongdan(){
         // Constructor of father class.
         ControlBase::ControlBase();
    }

    //==========================================================================
    // Function    : execute
    // Creator     : Oanhhtk 2007.03.15
    // Details     : Execute the process depend the given mode, 
    //               as: Add, Delete, Edit and default is List.
    //==========================================================================
     function execute($action=""){
        global $db, $arrayError, $_POST;
        $arrayData =  array();
        // Get back the work you want to do.
        $this->modul = CM_getParameter(MODUL);
        if ($action==""){
            // Get back the action: as: Add, Delete, Edit or List.
             $action = CM_getParameter(ACTION);
        }
        
        // Get data
        include_once(DIR_MODEL."md_huong_dan.class.php");
        $objHuongdan = new MD_Huongdan($this->db);
        
        switch($action){  
			 case "View":
                 // Get a record with given id
				 
                 $id = CM_getParameter("id");
				 $arrayData = $objHuongdan->getById($id);
                 // Error processing
                 if(empty($arrayData)){
                    $arrayError[]="Không tìm thấy bản ghi nào có id=".$id;
                 } 
                 // Show data
                 include_once(DIR_VIEW."v_huong_dan_view.php");                   
                 V_HuongdanView(&$arrayData,"View");
                 // update SoLanXem + 1
                $objHuongdan->updateSoLanXem($id);       
                 break; 
			default :{
				$arrayData = $objHuongdan->getById(1);
                 // Error processing
                 if(empty($arrayData)){
                    $arrayError[]="Không tìm thấy bản ghi nào có id=".$id;
                 } 
                 // Show data
                 include_once(DIR_VIEW."v_huong_dan_view.php");                   
                 V_HuongdanView(&$arrayData,"View");
                 // update SoLanXem + 1
                $objHuongdan->updateSoLanXem($id);       
                 break; 
			}            
        }
        unset($arrayData);
    }      
} 
?>